// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/maintain/api/AppPlanTaskApi'

import OneClass from '@api/maintain/model/AppQueryPlanTaskDetailReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 单项 —————————————————————————————— //

  validOne(one) {
    return one.id
  },
  async getOne({ id }, TIP = '查询任务详情') {
    const DTO = CORE.grpcDTO(OneClass, { planTaskId: id })
    const resp = await CORE.grpc(TIP, CLIENT, 'queryAppPlanTaskDetail', DTO)
    const { planTaskDto = {}, planTaskEventDto = [] } = resp
    return { ...planTaskDto, planTaskEventDto }
  },
  transOne(obj) {
    const tab = obj.handleStatus === 1 ? '1' : '2'
    return { ...obj, tab }
  },
}
